{include file="common/head"/}
<div class="admin-main layui-anim layui-anim-upbit">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>添加管理员</legend>
    </fieldset>
    <form class="layui-form layui-form-pane">
        <div class="layui-form-item">
            <label class="layui-form-label">所属组</label>
            <div class="layui-input-4">
				<input type="hidden" value="{$info.id}" name="id"/>
                <select name="group_id" lay-verify="required">
                    <option value="">请选择所属组</option>
					{volist name="auth_group" id="auth_group"}
						<option {if condition="$info['group_id'] == $auth_group['id']"}selected{/if} value="{$auth_group['id']}">{$auth_group['title']}</option>	
					{/volist}
                </select>
            </div>
        </div>
		
		<div class="layui-form-item">
            <label class="layui-form-label">账号</label>
            <div class="layui-input-4">
                <input type="text" maxlength="20" lay-verify="required" name="username" value="{$info.username}" placeholder="请输入账号" class="layui-input"/>
            </div>
        </div>
		<div class="layui-form-item">
            <label class="layui-form-label">真实姓名</label>
            <div class="layui-input-4">
                <input type="text" value="{$info.name}" maxlength="20" lay-verify="required" name="name" placeholder="请输入真实姓名" class="layui-input"/>
            </div>
        </div>
        
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="button" id="submit" class="layui-btn" lay-submit="" lay-filter="submit">{:lang('submit')}</button>
                <a href="{:url('index')}" class="layui-btn layui-btn-primary">{:lang('back')}</a>
            </div>
        </div>
    </form>
</div>
{include file="common/foot"/}
<script> 
        layui.use(['form', 'layer'], function () {
            var form = layui.form, layer = layui.layer,$= layui.jquery;
			form.render();
		 
            form.on('submit(submit)', function (data) {
				$("#submit").attr({ disabled: "disabled" });
                loading =layer.load(1, {shade: [0.1,'#fff']});
				
				if(data.field.county_id.length>7){
					data.field.county_id = data.field.county_id.substr(7);
				}
				if(data.field.city_id.length>7){
					data.field.city_id = data.field.city_id.substr(7);
				}
                $.post("", data.field, function (res) {
                    layer.close(loading);
					if (res.errorCode == 8888) {
                        layer.msg(res.msg, {time: 1800, icon: 1}, function () {
                            location.href = res.url;
                        });
                    } else {
						$("#submit").removeAttr("disabled");
                        layer.msg(res.msg, {time: 1800, icon: 2});
                    }
                });
            })
        });
    
</script>